package com.mlh.exception;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 缪林辉
 * @date 2024/12/10 11:32
 * @DESCRIPTION
 */
@Controller
@RequestMapping(value = "/exception")
public class TestExceptionHandler {

    @RequestMapping(value = "/test1")
    public String getException(){
        throw new AgeException();
    }

    // @ExceptionHandler(value = AgeException.class)
    public String innerHandleException(Exception exception, HttpServletRequest request){
        System.out.println("内部异常处理"+exception.getMessage());
        request.setAttribute("reason",exception.getMessage());
        return "exception_mes";
    }
}
